This invention relates generally to computer graphics. More particularly, this invention relates to dynamically changing the color depth of objects stored in the memory of a computer system for display.
In the field of computer graphics, computer programs such as applications and system programs create and display objects on display devices. The objects such as bitmaps, pens and brushes are composed of pixels and have a color depth measured in bits per pixel. They are displayed on devices such as video display terminals and printers that also have a color depth. A display device may be set to one of a number of color depths through a display driver, which is a software routine that controls the operation of the device in response to commands from the computer""s operating system or an application. For example, a video display terminal may have color depths such as of 1, 4, 12, 24 or 32 bits per pixel (bpp) which is set by its display driver, the greater number of bits providing a wider range of colors.
In typical operation, the color depths of display devices connected to a computer system are stored in a file maintained by the operating system, and each display device reads its color depth upon system startup. Thus printer A may read a color depth of 32 bpp, printer B may read a color depth of 24 bpp, and the video display terminal may read a color depth of 8 bpp. The display drivers create objects in system memory with the color depth of the device. For example, bitmaps may be created by the display driver for the video display terminal and then stored in system memory for later transfer (e.g., copy) to screen memory for display.
A drawback of present computer systems is the difficulty in rapidly changing the color depth of existing objects in system memory if the color depth of the device for displaying the object is changed after an object""s creation. For example, if a user uses an application to create device dependent bitmaps (DDBs) at 16 bpp and then changes the color depth of the display device to 24 bpp, the 16 bpp bitmaps cannot be properly displayed on the device. The user must first convert these bitmaps to the proper color depth by saving the bitmaps to disk as device independent bitmaps (DIBs), close the application that created them, and then reboot the computer system and reopen the applications to change to the new color depth. The bitmaps are then recreated in system memory as DDBs with the new color depth. Of course, objects created after the color depth is changed are not affected since they are created with the proper color depth.
An alternative to the use of DDBs is to store all objects as DIBs in system memory, which objects are automatically converted to the color depth of the display device as they are transferred from system memory to screen memory. However, this conversion, which occurs on each and every transfer, is time consuming and repetitive and slows the transfer process to the point that operation of the computer system is affected. For that reason, applications normally store objects in system memory as DDBs rather than DIBs to minimize the transfer time.
Presently there is no practical alternative to the slow and tedious process of closing applications and rebooting the computer system. The problem is bad enough with a single application, but is aggravated when multiple programs are executing in a multitasking environment. For example, a user may run a word processor at one color depth and then open a drawing application at another color depth with which he or she desires to create drawings. If the user wishes to increase the color depth for the drawing, he must close both applications, change the color depth, reboot the system, and then reopen the applications. Unless this process is followed, the bitmaps created before the color depth change cannot be accurately displayed.
An objective of the invention, therefore, is to provide for dynamically changing the color depth of existing objects in system memory to match the color depth of the display device, thereby avoiding the need to close applications, reboot the computer system and reopen the application.
A method according to the invention for dynamically changing the color depth of an object stored in memory includes the following steps. In response to a change in the color depth of a display device such as a video display terminal, the changed color depth is determined. Objects in the system memory whose color depth differs from the changed color depth are then found. The objects are then converted while in memory to the changed color depth. Unlike prior approaches, the objects need not be saved to disk and the applications shut down during a reboot of the computer system. The invention thus provides a much faster and simpler method for changing color depth.
In one embodiment of the invention, individual objects are found as they are selected for transfer to the display device, such as to the screen memory of the video display terminal. The objects may be checked to determine which must be converted to the changed color depth. Converting these identified objects includes making in system memory a copy of the object from an original (the copy having the changed color depth), transferring the copy to the display device as it is drawn, and retaining the original object and discarding the copy from system memory.
In another embodiment of the invention, all of the objects in system memory are found once the color depth has been changed. Converting the objects to the changed color depth then includes making in system memory copies of all of the objects from originals once the objects are found, transferring the copies to the display device as they are drawn, and retaining the copies and discarding the original objects from system memory.
The change in color depth of the display device may be initiated in any number of ways, such as manually by the user working through a utility program or automatically by an application that has a preferred color depth for objects it creates.
The foregoing and other objects, features, and advantages of the invention will become more apparent from the following detailed description of a preferred embodiment which proceeds with reference to the accompanying drawings.